/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.jee.lib.bo;

import java.util.ArrayList;
import uit.jee.lib.access.mapper.AuthorMapper;
import uit.jee.lib.dto.AuthorDTO;
import uit.jee.lib.dto.BookDTO;

/**
 *
 * @author ngloc_it
 */
public class AuthorBO {

    /**
     * Get list author
     * @return list author
     * @throws Exception
     */
    public ArrayList<AuthorDTO> GetAllAuthor() throws Exception{
        AuthorMapper mapper = new AuthorMapper();
        return mapper.GetAllAuthor();
    }

    /**
     * get an author by his name
     * @param name
     * @return
     * @throws Exception
     */
    public AuthorDTO GetAuthorByName(String name) throws Exception{
        AuthorMapper mapper = new AuthorMapper();
        return mapper.GetAuthorByName(name);
    }

    /**
     * Get an author by his id
     * @param id author's id
     * @return an author
     * @throws Exception
     */
    public AuthorDTO GetAuthorById(String id) throws Exception{
        AuthorMapper mapper = new AuthorMapper();
        return mapper.GetAuthorById(id);
    }

    /**
     * Get author by a book's id
     * @param bookId
     * @return
     * @throws Exception
     */
    public AuthorDTO GetAuthor(String bookId) throws Exception{
        AuthorMapper mapper = new AuthorMapper();
        return mapper.GetAuthor(bookId);
    }

    public AuthorDTO GetAuthor(BookDTO book) throws Exception{
        AuthorMapper mapper = new AuthorMapper();
        return mapper.GetAuthor(book);
    }
}
